package cn.ekuma.data.ui.android.editor;

import com.openbravo.data.basic.BasicException;
import com.openbravo.data.user.I_AndroidBrowsableEditableData;
import com.openbravo.data.user.I_BrowsableEditableData;
import com.openbravo.data.user.StateListener;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import cn.ekuma.data.ui.android.R;

public class JSaver  implements StateListener{
	I_AndroidBrowsableEditableData m_bd;
	
   public JSaver(I_AndroidBrowsableEditableData db){
		this.m_bd=db;
		m_bd.addStateListener(this);
	}

    public void updateState(int iState) {

    }

	 /**public void updateState(int iState) {
	        switch  (iState) {
	        case I_BrowsableEditableData.ST_INSERT:
	            jbtnNew.setEnabled(m_bd.canInsertData());
	            jbtnDelete.setEnabled(false);
	            jbtnSave.setEnabled(m_bd.canInsertData());
	            break;
	        case I_BrowsableEditableData.ST_DELETE:
	            jbtnNew.setEnabled(m_bd.canInsertData());
	            jbtnDelete.setEnabled(false);
	            jbtnSave.setEnabled(m_bd.canDeleteData());
	            break;
	        case I_BrowsableEditableData.ST_NORECORD:
	            jbtnNew.setEnabled(m_bd.canInsertData());
	            jbtnDelete.setEnabled(false);
	            jbtnSave.setEnabled(false);
	            break;
	        case I_BrowsableEditableData.ST_UPDATE:
	            jbtnNew.setEnabled(m_bd.canInsertData());
	            jbtnDelete.setEnabled(m_bd.canDeleteData());
	            jbtnSave.setEnabled(m_bd.canUpdateData());
	            break;
	        }
	   }   */
	 
	    public void jbtnSaveActionPerformed() {//GEN-FIRST:event_jbtnSaveActionPerformed
	        // Add your handling code here:
	        try {
	            m_bd.saveData();
	        } catch (BasicException eD) {
	            
	        }          
	    }//GEN-LAST:event_jbtnSaveActionPerformed

	    public void jbtnDeleteActionPerformed() {//GEN-FIRST:event_jbtnDeleteActionPerformed
	        // Add your handling code here:
	        try {
	            m_bd.actionDelete();
	        } catch (BasicException eD) {
	           
	        }        
	    }//GEN-LAST:event_jbtnDeleteActionPerformed

	    public void jbtnNewActionPerformed() {//GEN-FIRST:event_jbtnNewActionPerformed
	        // Add your handling code here:
	        try {
	            m_bd.actionInsert();
	        } catch (BasicException eD) {
	           
	        }
	    }//GEN-LAST:event_jbtnNewActionPerformed
}
